#include "ParticleAdhesiveContent.h"

#include "ParticleContext.h"
#include "DescriptorParticle.h"

using namespace ParticleEngine; 

const DescriptorParticle ParticleAdhesiveContent::Descriptor
(
	"AdhesiveContent", 
	[](ParticleContext& NewEng) { return new ParticleAdhesiveContent(NewEng); }
); 

ParticleAdhesiveContent::ParticleAdhesiveContent(ParticleContext& NewEng) :
	ParticleBase(NewEng, &ParticleAdhesiveContent::Descriptor),
	Heat(1.f)
{
	Adhesions = new PropertyAdhesions(0.1f);
	Adhesions->ParticleCast = this;
}
ParticleAdhesiveContent::~ParticleAdhesiveContent()
{
}

void ParticleAdhesiveContent::Sole()//einzelne aktualisierzung
{
	this->SoleStandard();
	Heat.Sole();
}
void ParticleAdhesiveContent::InteractionIndividual(ParticleBase*const Other, Vec<2, float>& Space, const float& DistanceSquared)
{
	this->InteractionKinetics(Other, Space, DistanceSquared);

	Heat.Interaction(Other->HasHeat());
}

ColorRGBA<unsigned char> ParticleAdhesiveContent::GetColor()
{
	const unsigned char f = (int)(this->HasHeat()->Volume * 255);
	return ColorRGBA<unsigned char> (f, 	0,	255-f,	255);
}

void ParticleAdhesiveContent::SaveIndividual(std::ofstream& Strm)
{
	Heat.Save(Strm);
}
void ParticleAdhesiveContent::LoadIndividual(std::ifstream& Strm)
{
	Heat.Load(Strm);
}


